home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / as400 / tracker / tracker.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-12-02  |  22.3 KB  |  638 lines

  1. VERSION 2.00
  2. Begin Form frmTracker 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "AS/400 Library Backup Tracker"
  5.    ClientHeight    =   4020
  6.    ClientLeft      =   840
  7.    ClientTop       =   1635
  8.    ClientWidth     =   7365
  9.    Height          =   4425
  10.    Icon            =   TRACKER.FRX:0000
  11.    Left            =   780
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   4020
  15.    ScaleWidth      =   7365
  16.    Top             =   1290
  17.    Width           =   7485
  18.    Begin ComboBox cboSystems 
  19.       FontBold        =   0   'False
  20.       FontItalic      =   0   'False
  21.       FontName        =   "MS Sans Serif"
  22.       FontSize        =   8.25
  23.       FontStrikethru  =   0   'False
  24.       FontUnderline   =   0   'False
  25.       Height          =   300
  26.       Left            =   120
  27.       Sorted          =   -1  'True
  28.       TabIndex        =   0
  29.       Top             =   360
  30.       Width           =   1455
  31.    End
  32.    Begin Grid grdHistory 
  33.       Cols            =   6
  34.       FixedCols       =   0
  35.       FixedRows       =   0
  36.       FontBold        =   0   'False
  37.       FontItalic      =   0   'False
  38.       FontName        =   "MS Sans Serif"
  39.       FontSize        =   8.25
  40.       FontStrikethru  =   0   'False
  41.       FontUnderline   =   0   'False
  42.       Height          =   2895
  43.       Left            =   120
  44.       Rows            =   100
  45.       TabIndex        =   2
  46.       Top             =   960
  47.       Width           =   7095
  48.    End
  49.    Begin ComboBox cboLibraries 
  50.       FontBold        =   0   'False
  51.       FontItalic      =   0   'False
  52.       FontName        =   "MS Sans Serif"
  53.       FontSize        =   8.25
  54.       FontStrikethru  =   0   'False
  55.       FontUnderline   =   0   'False
  56.       Height          =   300
  57.       Left            =   1800
  58.       Sorted          =   -1  'True
  59.       Style           =   2  'Dropdown List
  60.       TabIndex        =   1
  61.       Top             =   360
  62.       Width           =   1455
  63.    End
  64.    Begin CommandButton cmdDelete 
  65.       Caption         =   "&Delete"
  66.       Height          =   495
  67.       Left            =   4920
  68.       TabIndex        =   4
  69.       Top             =   120
  70.       Width           =   975
  71.    End
  72.    Begin CommandButton cmdUpdate 
  73.       Caption         =   "&Update"
  74.       Height          =   495
  75.       Left            =   3600
  76.       TabIndex        =   3
  77.       Top             =   120
  78.       Width           =   975
  79.    End
  80.    Begin CommandButton cmdExit 
  81.       Caption         =   "E&xit"
  82.       Height          =   495
  83.       Left            =   6240
  84.       TabIndex        =   5
  85.       Top             =   120
  86.       Width           =   975
  87.    End
  88.    Begin Label zlblSystems 
  89.       Alignment       =   2  'Center
  90.       BackColor       =   &H00808080&
  91.       Caption         =   "System"
  92.       ForeColor       =   &H00FFFFFF&
  93.       Height          =   255
  94.       Left            =   120
  95.       TabIndex        =   8
  96.       Top             =   120
  97.       Width           =   1455
  98.    End
  99.    Begin Label zlblHistory 
  100.       Alignment       =   2  'Center
  101.       BackColor       =   &H00808080&
  102.       Caption         =   "Backup History"
  103.       ForeColor       =   &H00FFFFFF&
  104.       Height          =   255
  105.       Left            =   120
  106.       TabIndex        =   7
  107.       Top             =   720
  108.       Width           =   7095
  109.    End
  110.    Begin Label zlblLibraries 
  111.       Alignment       =   2  'Center
  112.       BackColor       =   &H00808080&
  113.       Caption         =   "Library"
  114.       ForeColor       =   &H00FFFFFF&
  115.       Height          =   255
  116.       Left            =   1800
  117.       TabIndex        =   6
  118.       Top             =   120
  119.       Width           =   1455
  120.    End
  121. Option Explicit
  122.  ' Constants:
  123.   Const lNO_CALLBACK = 0&                   ' no call back used in TRACKER
  124.   Const nMAX_NUMBER_OF_RECORDS = 100        ' maximum number of records shown
  125.   Const sNO_BACKUP_DATE = "01/01/01"        ' a backup record not found
  126.   Const sNO_BACKUP_RECORD = "None"          ' a backup record not found
  127.   Const sNO_BACKUP_TIME = "00:00:00"        ' a backup record not found
  128.   Const sSAVE_FILE = "Save file "           ' save device when save file used
  129.   Const sSYSTEM_LIBRARY = "QSYS"            ' system library
  130.  ' Variables:
  131.   Dim sPriorSystem As String                ' last AS400 choosen
  132. Sub cboLibraries_Click ()
  133.  ' Description:
  134.  '  When library selected put backup
  135.  '  records into grid
  136.  ' Variable:
  137.   Dim nNumberofRecords  As Integer ' number of clip rows written
  138.   Dim nVolumeNumber     As Integer ' current tape volume number
  139.   Dim sClip             As String  ' data to put into clip
  140.   Dim sVolume           As String  ' current tape volume
  141.   ' please wait...
  142.   Screen.MousePointer = HOURGLASS
  143.   ' handle errors
  144.   On Error Resume Next
  145.   ' find first record
  146.   tblBackup.Index = "Primary"
  147.   tblBackup.Seek ">=", cboSystems.Text, sSYSTEM_LIBRARY, cboLibraries.List(cboLibraries.ListIndex)
  148.   If tblBackup.NoMatch = False Then
  149.     ' loop to read all records into grid
  150.     Do While Trim$(cboSystems.Text) = Trim$(tblBackup("System")) And sSYSTEM_LIBRARY = Trim$(tblBackup("Library")) And Trim$(cboLibraries.Text) = Trim$(tblBackup("Object"))
  151.       ' can only handle maximum number of records
  152.       If nNumberofRecords = nMAX_NUMBER_OF_RECORDS Then Exit Do
  153.       ' 1st column is empty
  154.       sClip = sClip & gsCHR_TAB
  155.       ' if no backup command then
  156.       If tblBackup("Command") = sNO_BACKUP_RECORD Then
  157.     ' no backups present
  158.     sClip = sClip & Format$(Date$, "SHORT DATE") & gsCHR_TAB
  159.     sClip = sClip & Format$(Time$, "MEDIUM TIME") & gsCHR_TAB
  160.     sClip = sClip & "No Backups"
  161.       ' valid backup record
  162.       Else
  163.     ' add date
  164.     sClip = sClip & Format$(tblBackup("When"), "SHORT DATE") & gsCHR_TAB
  165.     ' add time
  166.     sClip = sClip & Format$(tblBackup("When"), "MEDIUM TIME") & gsCHR_TAB
  167.     ' add command
  168.     sClip = sClip & tblBackup("Command") & gsCHR_TAB
  169.     ' add device
  170.     sClip = sClip & tblBackup("Device") & gsCHR_TAB
  171.     ' if save file used
  172.     If tblBackup("Device") = sSAVE_FILE Then
  173.       ' extract save file and library
  174.       sClip = sClip & tblBackup("Volumes") & gsCHR_TAB
  175.     ' if tape volumes used
  176.     Else
  177.       ' extract volume 1
  178.       sClip = sClip & zzStrExtract((tblBackup("Volumes")), 1, 6)
  179.        
  180.       ' extract volumes 2-10
  181.       For nVolumeNumber = 2 To 10
  182.         sVolume = zzStrExtract((tblBackup("Volumes")), nVolumeNumber, 6)
  183.         If Len(sVolume) > 0 Then sClip = sClip & "," & sVolume Else Exit For
  184.       Next nVolumeNumber
  185.     End If
  186.       End If
  187.       
  188.       ' add new row indicator
  189.       sClip = sClip & gsCHR_CR
  190.       ' increment counter
  191.       nNumberofRecords = nNumberofRecords + 1
  192.       ' get next, if none then exit
  193.       tblBackup.MoveNext
  194.       If tblBackup.EOF = True Then Exit Do
  195.     Loop
  196.   End If
  197.   ' reset rows to current number
  198.   If nNumberofRecords = 0 Then nNumberofRecords = nMAX_NUMBER_OF_RECORDS
  199.   grdHistory.Rows = nNumberofRecords
  200.   ' add data to grid
  201.   grdHistory.SelStartRow = 0
  202.   grdHistory.SelEndRow = nNumberofRecords - 1
  203.   grdHistory.SelStartCol = 0
  204.   grdHistory.SelEndCol = 5
  205.   grdHistory.Clip = sClip
  206.   grdHistory.Row = 0
  207.   grdHistory_Click
  208.   ' ...no more waiting
  209.   Screen.MousePointer = DEFAULT
  210. End Sub
  211. Sub cboSystems_Change ()
  212.   ' cannot be longer than eight characters
  213.   If Len(cboSystems.Text) > 8 Then
  214.     cboSystems.Text = Left$(cboSystems.Text, 8)
  215.     cboSystems.SelStart = 8
  216.   End If
  217. End Sub
  218. Sub cboSystems_Click ()
  219.   ' if different system selected
  220.   If sPriorSystem <> cboSystems.Text Then zfUpdateLibraryList
  221. End Sub
  222. Sub cboSystems_GotFocus ()
  223.   ' store current system selected
  224.   sPriorSystem = cboSystems.Text
  225. End Sub
  226. Sub cboSystems_KeyDown (KeyCode As Integer, Shift As Integer)
  227.   ' enter is same as click
  228.   If KeyCode = KEY_RETURN Then
  229.     If sPriorSystem <> cboSystems.Text Then
  230.       zfUpdateLibraryList
  231.     End If
  232.   End If
  233. End Sub
  234. Sub cboSystems_KeyPress (KeyAscii As Integer)
  235.   ' convert to upper case
  236.   KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
  237. End Sub
  238. Sub cboSystems_LostFocus ()
  239.   ' if different system selected
  240.   If sPriorSystem <> cboSystems.Text Then zfUpdateLibraryList
  241. End Sub
  242. Sub cmdDelete_Click ()
  243.  ' Description:
  244.  '  Delete selected backup records
  245.  ' Variables:
  246.   Dim nPriorListIndex   As Integer     ' list index for cboLibraries
  247.   Dim sDeleteDate       As String      ' date selected by user
  248.   Dim vntNumericDate    As Variant     ' valid date checker
  249.   ' build message to be displayed
  250.   gsMBText = "All backup records for library " & RTrim$(cboLibraries.Text)
  251.   gsMBText = gsMBText & " dated prior to date entered below"
  252.   gsMBText = gsMBText & " will be deleted."
  253.   ' loop until cancel choosen or valid date entered
  254.     sDeleteDate = InputBox(gsMBText, App.Title)
  255.     If sDeleteDate = gsEMPTY Then Exit Sub
  256.     ' use date value function to validate date
  257.     On Error Resume Next
  258.     vntNumericDate = DateValue(sDeleteDate)
  259.     On Error GoTo 0
  260.   Loop Until vntNumericDate <> 0
  261.   ' use primary index
  262.   tblBackup.Index = "Primary"
  263.   ' if first record found
  264.   tblBackup.Seek ">=", cboSystems.Text, sSYSTEM_LIBRARY, cboLibraries.Text
  265.   If tblBackup.NoMatch = False Then
  266.     ' loop to read all matching records for system and library
  267.     Do While Trim$(tblBackup("System")) = Trim$(cboSystems.Text) And Trim$(tblBackup("Library")) = sSYSTEM_LIBRARY And Trim$(tblBackup("Object")) = Trim$(cboLibraries.Text)
  268.      ' if before selected date then delete
  269.      If DateValue(tblBackup("When")) < vntNumericDate Then
  270.        tblBackup.Delete
  271.      End If
  272.      ' get next record
  273.      tblBackup.MoveNext
  274.      If tblBackup.EOF Then Exit Do
  275.     Loop
  276.   End If
  277.   ' save for reset after library rebuild
  278.   nPriorListIndex = cboLibraries.ListIndex
  279.   ' relist libraries
  280.   zfUpdateLibraryList
  281.   ' reset to library selected
  282.   If cboLibraries.ListCount > nPriorListIndex Then
  283.     cboLibraries.ListIndex = nPriorListIndex
  284.   End If
  285. End Sub
  286. Sub cmdExit_Click ()
  287.   ' unload main form
  288.   Unload Me
  289. End Sub
  290. Sub cmdUpdate_Click ()
  291.  ' Description:
  292.  '  Perform process which will generate AS/400
  293.  '  file which contains latest backup information
  294.  '  and then download that file to the personal
  295.  '  computer and update the Tracker data base.
  296.  ' Variables:
  297.   ' dspobjd command variables
  298.   Dim nCmdRC              As Integer  ' return code
  299.   Dim nRecordsDownloaded  As Integer  ' total records downloaded
  300.   Dim nRecordsUpdated     As Integer  ' total records updated
  301.   Dim sCmd                As String   ' command to submit
  302.   Dim sCmdMsgs            As String   ' messages returned
  303.   Dim sLibsNotBackedup    As String   ' list of librarys not backed up
  304.   ' save information
  305.   Dim sSaveCentury        As String   ' century
  306.   Dim sSaveCmd            As String   ' command
  307.   Dim sSaveDate           As String   ' date
  308.   Dim sSaveDevice         As String   ' device
  309.   Dim sSaveLibrary        As String   ' library
  310.   Dim sSaveObj            As String   ' object
  311.   Dim sSaveTime           As String   ' time
  312.   Dim sSaveVols           As String   ' volumes 1-10 or SaveFile
  313.   Dim vntSaveDateAndTime  As Variant  ' date and time
  314.   ' file transfer variables
  315.   Dim lTfrConvID          As Long     ' conversation id
  316.   Dim nTfrRC              As Integer  ' return code
  317.   Dim nTfrNumTemplates    As Integer  ' number of fields
  318.   Dim sTfrDataRtnd        As String   ' data returned
  319.   Dim sTfrRequest         As String   ' buffer
  320.   ' disable all controls
  321.   Call ControlsEnabled(False)
  322.   ' does user want to continue with process
  323.   If MsgBox("Are you sure you want to update backup history for " & cboSystems.Text & " at this time?", MB_YESNO Or MB_ICONQUESTION) = IDYES Then
  324.     ' build the DSPOBJD command
  325.     sCmd = "DSPOBJD "
  326.     sCmd = sCmd & "OBJ(QSYS/*ALL) "
  327.     sCmd = sCmd & "OBJTYPE(*LIB) "
  328.     sCmd = sCmd & "OUTPUT(*OUTFILE) "
  329.     sCmd = sCmd & "OUTFILE(QGPL/LIBLIST4VB)"
  330.     ' please wait...
  331.     Screen.MousePointer = HOURGLASS
  332.     ' execute command
  333.     nCmdRC = zzSRCmdFormatMsgsAndEnd(Me.hWnd, cboSystems.Text, sCmd, sCmdMsgs)
  334.     ' ...no more waiting
  335.     Screen.MousePointer = DEFAULT
  336.     ' if command worked
  337.     If nCmdRC = gnSR_OK Then
  338.       ' build transfer request
  339.       sTfrRequest = "SELECT * FROM QGPL/LIBLIST4VB"
  340.       
  341.       ' please wait...
  342.       Screen.MousePointer = HOURGLASS
  343.       
  344.       ' execute file transfer
  345.       nTfrRC = zzTFOpen(Me.hWnd, lNO_CALLBACK, lTfrConvID, sTfrRequest, cboSystems.Text, nTfrNumTemplates)
  346.       
  347.       ' ...no more waiting
  348.       Screen.MousePointer = DEFAULT
  349.       ' if select worked
  350.       If nTfrRC = gnTF_OK Then
  351.     ' clear fields
  352.     sLibsNotBackedup = gsEMPTY
  353.     nRecordsDownloaded = 0
  354.     nRecordsUpdated = 0
  355.     ' please wait...
  356.     Screen.MousePointer = HOURGLASS
  357.     ' set beginning of transactions
  358.     dbBackup.BeginTrans
  359.     ' retrieve records
  360.       DoEvents
  361.       ' get next record
  362.       nTfrRC = zzTFGetRecord(Me.hWnd, lNO_CALLBACK, lTfrConvID, cboSystems.Text, gnTF_NO_CONVERSION, sTfrDataRtnd)
  363.       
  364.       ' exit on error or EOF
  365.       If nTfrRC <> gnTF_OK Then Exit Do
  366.       ' increment counter
  367.       nRecordsDownloaded = nRecordsDownloaded + 1
  368.       ' get library, object, and save century
  369.       sSaveLibrary = zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 14, 10))
  370.       sSaveObj = zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 24, 10))
  371.       sSaveCentury = RTrim$(zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 134, 1)))
  372.       ' show user object name
  373.       zlblLibraries.Caption = RTrim$(sSaveObj)
  374.       zlblLibraries.Refresh
  375.       ' not saved
  376.       If sSaveCentury = gsEMPTY Then
  377.         ' add to list for later message box
  378.         sLibsNotBackedup = sLibsNotBackedup & RTrim$(sSaveObj) & ", "
  379.         sSaveDate = sNO_BACKUP_DATE
  380.         sSaveTime = sNO_BACKUP_TIME
  381.         sSaveCmd = sNO_BACKUP_RECORD
  382.         sSaveDevice = sNO_BACKUP_RECORD
  383.         sSaveVols = sNO_BACKUP_RECORD
  384.       ' saved
  385.       Else
  386.         ' get date and format it
  387.         sSaveDate = zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 135, 6))
  388.         sSaveCentury = IIf(sSaveCentury = "0", "19", "20")
  389.         sSaveDate = DateSerial(Val(sSaveCentury & Mid$(sSaveDate, 5, 2)), Val(Mid$(sSaveDate, 1, 2)), Val(Mid$(sSaveDate, 3, 2)))
  390.         ' get time and format it
  391.         sSaveTime = zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 141, 6))
  392.         sSaveTime = Mid$(sSaveTime, 1, 2) & ":" & Mid$(sSaveTime, 3, 2) & ":" & Mid$(sSaveTime, 5, 2)
  393.         
  394.         ' get command, device, volume labels
  395.         sSaveCmd = zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 147, 10))
  396.         sSaveDevice = zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 165, 10))
  397.         ' if save file then get it
  398.         If sSaveDevice = sSAVE_FILE Then
  399.           sSaveVols = RTrim$(zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 371, 10)))
  400.           sSaveVols = sSaveVols & "/" & RTrim$(zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 361, 10)))
  401.         
  402.         ' if volumes used get them
  403.         Else
  404.           sSaveVols = zzCV_EBCDICtoASCII(Me.hWnd, Mid$(sTfrDataRtnd, 175, 60))
  405.         End If
  406.       End If
  407.       ' put date and time together
  408.       vntSaveDateAndTime = sSaveDate & " " & Format$(sSaveTime, "LONG TIME")
  409.       ' see if same record already exists
  410.       tblBackup.Index = "Primary"
  411.       tblBackup.Seek "=", cboSystems.Text, sSaveLibrary, sSaveObj, vntSaveDateAndTime
  412.       ' if it does not then write it
  413.       If tblBackup.NoMatch Then
  414.         
  415.         ' setup for new record
  416.         tblBackup.AddNew
  417.         
  418.         ' set fields
  419.         tblBackup("System") = cboSystems.Text
  420.         tblBackup("Library") = sSaveLibrary
  421.         tblBackup("Object") = sSaveObj
  422.         tblBackup("When") = vntSaveDateAndTime
  423.         tblBackup("Command") = sSaveCmd
  424.         tblBackup("Device") = sSaveDevice
  425.         tblBackup("Volumes") = sSaveVols
  426.         
  427.         ' update record
  428.         tblBackup.Update
  429.         
  430.         ' increment record count
  431.         nRecordsUpdated = nRecordsUpdated + 1
  432.       End If
  433.     Loop
  434.     ' execute tranactions
  435.     dbBackup.CommitTrans
  436.     ' close the conversation
  437.     nTfrRC = zzTFEndConversation(Me.hWnd, lNO_CALLBACK, lTfrConvID, cboSystems.Text)
  438.     ' ...no more waiting
  439.     Screen.MousePointer = DEFAULT
  440.     ' relist libraries
  441.     zfUpdateLibraryList
  442.     ' sendup and show completion message
  443.     gsMBText = "Update of backup records for " & cboSystems.Text & " complete. Backup information for "
  444.     gsMBText = gsMBText & Format$(nRecordsDownloaded) & " libraries was downloaded, "
  445.     If nRecordsUpdated = 0 Then
  446.       gsMBText = gsMBText & "no"
  447.     Else
  448.       gsMBText = gsMBText & Format$(nRecordsUpdated)
  449.     End If
  450.     gsMBText = gsMBText & " libraries were updated with more recent backup data."
  451.     If sLibsNotBackedup <> gsEMPTY Then
  452.       gsMBText = gsMBText & " The following libraries have not been backed up at all: "
  453.       gsMBText = gsMBText & Left$(sLibsNotBackedup, Len(sLibsNotBackedup) - 2) & "."
  454.     End If
  455.     MsgBox gsMBText, MB_ICONINFORMATION
  456.       
  457.       ' SELECT did not work
  458.       Else
  459.     gsMBText = "SELECT did not work, update terminated abnormally."
  460.     MsgBox gsMBText, MB_ICONSTOP
  461.       End If
  462.     ' DSPOBJD did not work
  463.     Else
  464.       gsMBText = sCmdMsgs
  465.       gsMBText = gsMBText & "Unable to display library descriptions."
  466.       gsMBText = gsMBText & " Update terminated abnormally."
  467.       MsgBox gsMBText, MB_ICONSTOP
  468.     End If
  469.   End If
  470.   ' enable controls
  471.   Call ControlsEnabled(True)
  472. End Sub
  473. Sub ControlsEnabled (ByVal bTrueorFalse%)
  474.  ' Description:
  475.  '  Turns controls off or on.
  476.   cboLibraries.Enabled = bTrueorFalse
  477.   cboSystems.Enabled = bTrueorFalse
  478.   cmdDelete.Enabled = bTrueorFalse
  479.   cmdExit.Enabled = bTrueorFalse
  480.   cmdUpdate.Enabled = bTrueorFalse
  481.   grdHistory.Enabled = bTrueorFalse
  482. End Sub
  483. Sub Form_Load ()
  484.  ' Description:
  485.  '  This procedure which runs when the Tracker
  486.  '  form is loaded: opens the data base file,
  487.  '  determines if the router is loaded, puts
  488.  '  the list of available systems into a
  489.  '  combo box, and setups the form location
  490.  '  and the grid specifications.
  491.  ' Variables:
  492.   Dim nSystemCount As Integer   ' number of systems
  493.   ' set caption to application title
  494.   Caption = App.Title & " [" & gsTrackerDir & "]"
  495.   ' open database
  496.   On Error Resume Next
  497.   Set dbBackup = OpenDatabase(gsTrackerDir & "\tracker.mdb", True, False)
  498.   Call ShowErrMsg
  499.   Set tblBackup = dbBackup.OpenTable("Backups")
  500.   Call ShowErrMsg
  501.   On Error GoTo 0
  502.   ' if router loaded then
  503.   If zzCARouterLoaded(Me.hWnd) Then
  504.     ' place list of AS/400s into control
  505.     Call zzCAPutSystemListIntoCtrl(Me.hWnd, cboSystems)
  506.     ' get count of systems
  507.     nSystemCount = zzCAGetSystemCount(Me.hWnd)
  508.     ' if systems available
  509.     If nSystemCount > 0 Then
  510.       ' display system count in label
  511.       zlblSystems.Caption = Format$(nSystemCount) & " System"
  512.       If nSystemCount > 1 Then zlblSystems.Caption = zlblSystems.Caption & "s"
  513.     Else
  514.       ' no update if no systems
  515.       cmdUpdate.Enabled = False
  516.     End If
  517.   ' no update if router not loaded
  518.   Else
  519.     cmdUpdate.Enabled = False
  520.   End If
  521.   ' center form
  522.   Call zzFormCenter(Me)
  523.   ' set grid rows and column widths
  524.   grdHistory.Rows = nMAX_NUMBER_OF_RECORDS
  525.   grdHistory.ColWidth(0) = 1
  526.   grdHistory.ColWidth(1) = TextWidth("99/99/9999")
  527.   grdHistory.ColWidth(2) = TextWidth("99:99 XX")
  528.   grdHistory.ColWidth(3) = TextWidth("XXXXXXXXXX")
  529.   grdHistory.ColWidth(4) = grdHistory.ColWidth(3)
  530.   grdHistory.ColWidth(5) = grdHistory.ColWidth(3) * 7
  531.   ' reset grid
  532.   grdHistory_Click
  533.   ' show the form
  534.   Show
  535.   Refresh
  536.   ' set to first system on list
  537.   If cboSystems.ListCount > 0 Then
  538.     cboSystems.ListIndex = 0
  539.   ' if no systems force clear of other controls
  540.   Else
  541.     Call zfUpdateLibraryList
  542.   End If
  543. End Sub
  544. Sub Form_Unload (Cancel As Integer)
  545.   ' handle errors
  546.   On Error Resume Next
  547.   ' close database
  548.   tblBackup.Close
  549.   dbBackup.Close
  550.   ' end program
  551.   End
  552. End Sub
  553. Sub grdHistory_Click ()
  554.  ' Description:
  555.  '  Make sure grid is reset when
  556.  '  user trys to click on it
  557.   ' no selected area
  558.   grdHistory.SelStartRow = 0
  559.   grdHistory.SelEndRow = 0
  560.   grdHistory.SelStartCol = 0
  561.   grdHistory.SelEndCol = 0
  562.   ' current column
  563.   grdHistory.Col = 0
  564.   ' always show left most column
  565.   grdHistory.LeftCol = 0
  566. End Sub
  567. Sub ShowErrMsg ()
  568.  ' Description:
  569.  '  Show error message
  570.  ' Parameters:
  571.  '  nErr          error number
  572.  ' Variables
  573.   ' if error occurred
  574.   If Err <> 0 Then
  575.     ' get and format message
  576.     gsMBText = Error$
  577.     If Right$(gsMBText, 1) <> "." Then
  578.        gsMBText = gsMBText & "."
  579.     End If
  580.     ' show message
  581.     MsgBox gsMBText, MB_ICONEXCLAMATION
  582.     ' reset error number
  583.     Err = 0
  584.   End If
  585. End Sub
  586. Sub zfUpdateLibraryList ()
  587.  ' Description:
  588.  '  Rebuild library combo box from database
  589.  ' Variables:
  590.   Dim nLibraryCount As Integer  ' count of libraries selected
  591.   Dim sPriorObject  As String  ' last object read from file
  592.   ' please wait...
  593.   Screen.MousePointer = HOURGLASS
  594.   ' update prior system choosen
  595.   sPriorSystem = cboSystems.Text
  596.   ' clear the library list
  597.   cboLibraries.Clear
  598.   ' turn on error handling
  599.   On Error Resume Next
  600.   ' use index with only system and library as key
  601.   tblBackup.Index = "Secondary"
  602.   ' loop til no more unique libraries
  603.     ' find next library for selected system
  604.     tblBackup.Seek ">", sPriorSystem, sSYSTEM_LIBRARY, sPriorObject
  605.     If tblBackup.NoMatch Then Exit Do
  606.     ' must be the same system
  607.     If tblBackup("System") <> sPriorSystem Then Exit Do
  608.     ' place library from record into control
  609.     sPriorObject = tblBackup("Object")
  610.     cboLibraries.AddItem sPriorObject
  611.     ' increment counter
  612.     nLibraryCount = nLibraryCount + 1
  613.     ' display every 50th library change
  614.     If nLibraryCount Mod 50 = 0 Then
  615.       zlblLibraries = Format$(nLibraryCount) & " Libraries"
  616.       zlblLibraries.Refresh
  617.     End If
  618.   Loop
  619.   ' no more error handling
  620.   On Error GoTo 0
  621.   ' refresh list and set delete button
  622.   If cboLibraries.ListCount > 0 Then
  623.     ' show final count
  624.     zlblLibraries = Format$(cboLibraries.ListCount) & " Libraries"
  625.     ' select first library
  626.     cboLibraries.ListIndex = 0
  627.     cmdDelete.Enabled = True
  628.   Else
  629.     ' no libraries found
  630.     zlblLibraries = "No Libraries"
  631.     ' reset the control
  632.     cboLibraries_Click
  633.     cmdDelete.Enabled = False
  634.   End If
  635.   ' ...no more waiting
  636.   Screen.MousePointer = DEFAULT
  637. End Sub
  638.